<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE CPP                       #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE ExistentialQuantification #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE MagicHash                 #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE UnboxedTuples             #-}</span><span>
</span><span id="line-5"></span><span class="hs-pragma">{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}</span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  GHC.StaticPtr</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (C) 2014 I/O Tweag</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- License     :  see libraries/base/LICENSE</span><span>
</span><span id="line-11"></span><span class="hs-comment">--</span><span>
</span><span id="line-12"></span><span class="hs-comment">-- Maintainer  :  cvs-ghc@haskell.org</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Stability   :  internal</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability :  non-portable (GHC Extensions)</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- Symbolic references to values.</span><span>
</span><span id="line-17"></span><span class="hs-comment">--</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- References to values are usually implemented with memory addresses, and this</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- is practical when communicating values between the different pieces of a</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- single process.</span><span>
</span><span id="line-21"></span><span class="hs-comment">--</span><span>
</span><span id="line-22"></span><span class="hs-comment">-- When values are communicated across different processes running in possibly</span><span>
</span><span id="line-23"></span><span class="hs-comment">-- different machines, though, addresses are no longer useful since each</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- process may use different addresses to store a given value.</span><span>
</span><span id="line-25"></span><span class="hs-comment">--</span><span>
</span><span id="line-26"></span><span class="hs-comment">-- To solve such concern, the references provided by this module offer a key</span><span>
</span><span id="line-27"></span><span class="hs-comment">-- that can be used to locate the values on each process. Each process maintains</span><span>
</span><span id="line-28"></span><span class="hs-comment">-- a global table of references which can be looked up with a given key. This</span><span>
</span><span id="line-29"></span><span class="hs-comment">-- table is known as the Static Pointer Table. The reference can then be</span><span>
</span><span id="line-30"></span><span class="hs-comment">-- dereferenced to obtain the value.</span><span>
</span><span id="line-31"></span><span class="hs-comment">--</span><span>
</span><span id="line-32"></span><span class="hs-comment">-- The various communicating processes need to aggree on the keys used to refer</span><span>
</span><span id="line-33"></span><span class="hs-comment">-- to the values in the Static Pointer Table, or lookups will fail. Only</span><span>
</span><span id="line-34"></span><span class="hs-comment">-- processes launched from the same program binary are guaranteed to use the</span><span>
</span><span id="line-35"></span><span class="hs-comment">-- same set of keys.</span><span>
</span><span id="line-36"></span><span class="hs-comment">--</span><span>
</span><span id="line-37"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-38"></span><span>
</span><span id="line-39"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.StaticPtr</span><span>
</span><span id="line-40"></span><span>  </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier">StaticPtr</span></a></span><span>
</span><span id="line-41"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#deRefStaticPtr"><span class="hs-identifier">deRefStaticPtr</span></a></span><span>
</span><span id="line-42"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticKey"><span class="hs-identifier">StaticKey</span></a></span><span>
</span><span id="line-43"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#staticKey"><span class="hs-identifier">staticKey</span></a></span><span>
</span><span id="line-44"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#unsafeLookupStaticPtr"><span class="hs-identifier">unsafeLookupStaticPtr</span></a></span><span>
</span><span id="line-45"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtrInfo"><span class="hs-identifier">StaticPtrInfo</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-46"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#staticPtrInfo"><span class="hs-identifier">staticPtrInfo</span></a></span><span>
</span><span id="line-47"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#staticPtrKeys"><span class="hs-identifier">staticPtrKeys</span></a></span><span>
</span><span id="line-48"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#IsStatic"><span class="hs-identifier">IsStatic</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-49"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-50"></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.C.Types.html"><span class="hs-identifier">Foreign.C.Types</span></a></span><span>     </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier">CInt</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Foreign.Marshal.html"><span class="hs-identifier">Foreign.Marshal</span></a></span><span>     </span><span class="hs-special">(</span><span class="annot"><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier">allocaArray</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.Marshal.Array.html#peekArray"><span class="hs-identifier">peekArray</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Foreign.Marshal.Array.html#withArray"><span class="hs-identifier">withArray</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Ptr.html"><span class="hs-identifier">GHC.Ptr</span></a></span><span>             </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier">Ptr</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier">nullPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Fingerprint.html"><span class="hs-identifier">GHC.Fingerprint</span></a></span><span>     </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Fingerprint.Type.html#Fingerprint"><span class="hs-identifier">Fingerprint</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#"><span class="hs-identifier">GHC.Prim</span></a></span><span>
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Word.html"><span class="hs-identifier">GHC.Word</span></a></span><span>            </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier">Word64</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-cpp">


#include &quot;MachDeps.h&quot;
</span><span>
</span><span id="line-61"></span><span class="hs-comment">-- | A reference to a value of type @a@.</span><span class="hs-cpp">
#if WORD_SIZE_IN_BITS &lt; 64
</span><span class="hs-keyword">data</span><span> </span><span class="hs-identifier">StaticPtr</span><span> </span><span class="hs-identifier">a</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-identifier">StaticPtr</span><span> </span><span class="hs-identifier">Word64#</span><span> </span><span class="hs-identifier">Word64#</span><span> </span><span class="hs-comment">-- The flattened Fingerprint is</span><span>
</span><span id="line-64"></span><span>                                             </span><span class="hs-comment">-- convenient in the compiler.</span><span>
</span><span id="line-65"></span><span>                             </span><span class="hs-identifier">StaticPtrInfo</span><span> </span><span class="hs-identifier">a</span><span class="hs-cpp">
#else
</span><span class="hs-keyword">data</span><span> </span><span id="StaticPtr"><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-var">StaticPtr</span></a></span></span><span> </span><span id="local-6989586621679564991"><span class="annot"><a href="#local-6989586621679564991"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="StaticPtr"><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-var">StaticPtr</span></a></span></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Word%23"><span class="hs-identifier hs-type">Word#</span></a></span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Prim.html#Word%23"><span class="hs-identifier hs-type">Word#</span></a></span><span>
</span><span id="line-68"></span><span>                             </span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtrInfo"><span class="hs-identifier hs-type">StaticPtrInfo</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679564991"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-cpp">
#endif
</span><span class="hs-comment">-- | Dereferences a static pointer.</span><span>
</span><span id="line-71"></span><span id="local-6989586621679565067"><span class="annot"><a href="GHC.StaticPtr.html#deRefStaticPtr"><span class="hs-identifier hs-type">deRefStaticPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-type">StaticPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679565067"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679565067"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-72"></span><span id="deRefStaticPtr"><span class="annot"><span class="annottext">deRefStaticPtr :: forall a. StaticPtr a -&gt; a
</span><a href="GHC.StaticPtr.html#deRefStaticPtr"><span class="hs-identifier hs-var hs-var">deRefStaticPtr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-type">StaticPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Word#
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Word#
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">StaticPtrInfo
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679564990"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679564990"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679564990"><span class="hs-identifier hs-var">v</span></a></span><span>
</span><span id="line-73"></span><span>
</span><span id="line-74"></span><span class="hs-comment">-- | A key for 'StaticPtr's that can be serialized and used with</span><span>
</span><span id="line-75"></span><span class="hs-comment">-- 'unsafeLookupStaticPtr'.</span><span>
</span><span id="line-76"></span><span class="hs-keyword">type</span><span> </span><span id="StaticKey"><span class="annot"><a href="GHC.StaticPtr.html#StaticKey"><span class="hs-identifier hs-var">StaticKey</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Fingerprint.Type.html#Fingerprint"><span class="hs-identifier hs-type">Fingerprint</span></a></span><span>
</span><span id="line-77"></span><span>
</span><span id="line-78"></span><span class="hs-comment">-- | The 'StaticKey' that can be used to look up the given 'StaticPtr'.</span><span>
</span><span id="line-79"></span><span id="local-6989586621679565065"><span class="annot"><a href="GHC.StaticPtr.html#staticKey"><span class="hs-identifier hs-type">staticKey</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-type">StaticPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679565065"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticKey"><span class="hs-identifier hs-type">StaticKey</span></a></span></span><span>
</span><span id="line-80"></span><span id="staticKey"><span class="annot"><span class="annottext">staticKey :: forall a. StaticPtr a -&gt; StaticKey
</span><a href="GHC.StaticPtr.html#staticKey"><span class="hs-identifier hs-var hs-var">staticKey</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-type">StaticPtr</span></a></span><span> </span><span id="local-6989586621679564989"><span class="annot"><span class="annottext">Word#
</span><a href="#local-6989586621679564989"><span class="hs-identifier hs-var">w0</span></a></span></span><span> </span><span id="local-6989586621679564988"><span class="annot"><span class="annottext">Word#
</span><a href="#local-6989586621679564988"><span class="hs-identifier hs-var">w1</span></a></span></span><span> </span><span class="annot"><span class="annottext">StaticPtrInfo
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; StaticKey
</span><a href="GHC.Fingerprint.Type.html#Fingerprint"><span class="hs-identifier hs-var">Fingerprint</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word# -&gt; Word64
</span><a href="GHC.Word.html#W64%23"><span class="hs-identifier hs-var">W64#</span></a></span><span> </span><span class="annot"><span class="annottext">Word#
</span><a href="#local-6989586621679564989"><span class="hs-identifier hs-var">w0</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Word# -&gt; Word64
</span><a href="GHC.Word.html#W64%23"><span class="hs-identifier hs-var">W64#</span></a></span><span> </span><span class="annot"><span class="annottext">Word#
</span><a href="#local-6989586621679564988"><span class="hs-identifier hs-var">w1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span class="hs-comment">-- | Looks up a 'StaticPtr' by its 'StaticKey'.</span><span>
</span><span id="line-83"></span><span class="hs-comment">--</span><span>
</span><span id="line-84"></span><span class="hs-comment">-- If the 'StaticPtr' is not found returns @Nothing@.</span><span>
</span><span id="line-85"></span><span class="hs-comment">--</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- This function is unsafe because the program behavior is undefined if the type</span><span>
</span><span id="line-87"></span><span class="hs-comment">-- of the returned 'StaticPtr' does not match the expected one.</span><span>
</span><span id="line-88"></span><span class="hs-comment">--</span><span>
</span><span id="line-89"></span><span id="local-6989586621679565062"><span class="annot"><a href="GHC.StaticPtr.html#unsafeLookupStaticPtr"><span class="hs-identifier hs-type">unsafeLookupStaticPtr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticKey"><span class="hs-identifier hs-type">StaticKey</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-type">StaticPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679565062"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span><span>
</span><span id="line-90"></span><span id="unsafeLookupStaticPtr"><span class="annot"><span class="annottext">unsafeLookupStaticPtr :: forall a. StaticKey -&gt; IO (Maybe (StaticPtr a))
</span><a href="GHC.StaticPtr.html#unsafeLookupStaticPtr"><span class="hs-identifier hs-var hs-var">unsafeLookupStaticPtr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Fingerprint.Type.html#Fingerprint"><span class="hs-identifier hs-type">Fingerprint</span></a></span><span> </span><span id="local-6989586621679564980"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679564980"><span class="hs-identifier hs-var">w1</span></a></span></span><span> </span><span id="local-6989586621679564979"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679564979"><span class="hs-identifier hs-var">w2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-91"></span><span>    </span><span id="local-6989586621679564978"><span class="annot"><span class="annottext">ptr :: Ptr Any
</span><a href="#local-6989586621679564978"><span class="hs-identifier hs-var">ptr</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span id="local-6989586621679564976"><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679564976"><span class="hs-identifier hs-var">addr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[Word64] -&gt; (Ptr Word64 -&gt; IO (Ptr Any)) -&gt; IO (Ptr Any)
forall a b. Storable a =&gt; [a] -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#withArray"><span class="hs-identifier hs-var">withArray</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679564980"><span class="hs-identifier hs-var">w1</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679564979"><span class="hs-identifier hs-var">w2</span></a></span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">Ptr Word64 -&gt; IO (Ptr Any)
forall a. Ptr Word64 -&gt; IO (Ptr a)
</span><a href="GHC.StaticPtr.html#hs_spt_lookup"><span class="hs-identifier hs-var">hs_spt_lookup</span></a></span><span>
</span><span id="line-92"></span><span>    </span><span class="hs-keyword">if</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Ptr Any
</span><a href="#local-6989586621679564978"><span class="hs-identifier hs-var">ptr</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Any -&gt; Ptr Any -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3D%3D"><span class="hs-operator hs-var">==</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr Any
forall a. Ptr a
</span><a href="GHC.Ptr.html#nullPtr"><span class="hs-identifier hs-var">nullPtr</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-93"></span><span>    </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe (StaticPtr a) -&gt; IO (Maybe (StaticPtr a))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (StaticPtr a)
forall a. Maybe a
</span><a href="GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-94"></span><span>    </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Addr# -&gt; (# StaticPtr a #)
forall a. Addr# -&gt; (# a #)
</span><a href="../../ghc-prim/src/GHC.Prim.html#addrToAny%23"><span class="hs-identifier hs-var">addrToAny#</span></a></span><span> </span><span class="annot"><span class="annottext">Addr#
</span><a href="#local-6989586621679564976"><span class="hs-identifier hs-var">addr</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-95"></span><span>           </span><span class="hs-special">(#</span><span> </span><span id="local-6989586621679564974"><span class="annot"><span class="annottext">StaticPtr a
</span><a href="#local-6989586621679564974"><span class="hs-identifier hs-var">spe</span></a></span></span><span> </span><span class="hs-special">#)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe (StaticPtr a) -&gt; IO (Maybe (StaticPtr a))
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">StaticPtr a -&gt; Maybe (StaticPtr a)
forall a. a -&gt; Maybe a
</span><a href="GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">StaticPtr a
</span><a href="#local-6989586621679564974"><span class="hs-identifier hs-var">spe</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-96"></span><span>
</span><span id="line-97"></span><span id="local-6989586621679565057"><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span id="hs_spt_lookup"><span class="annot"><a href="GHC.StaticPtr.html#hs_spt_lookup"><span class="hs-identifier hs-var">hs_spt_lookup</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="GHC.Word.html#Word64"><span class="hs-identifier hs-type">Word64</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679565057"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-98"></span><span>
</span><span id="line-99"></span><span class="hs-comment">-- | A class for things buildable from static pointers.</span><span>
</span><span id="line-100"></span><span class="hs-keyword">class</span><span> </span><span id="IsStatic"><span class="annot"><a href="GHC.StaticPtr.html#IsStatic"><span class="hs-identifier hs-var">IsStatic</span></a></span></span><span> </span><span id="local-6989586621679565049"><span class="annot"><a href="#local-6989586621679565049"><span class="hs-identifier hs-type">p</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-101"></span><span>    </span><span id="local-6989586621679565051"><span id="fromStaticPtr"><span class="annot"><a href="GHC.StaticPtr.html#fromStaticPtr"><span class="hs-identifier hs-type">fromStaticPtr</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-type">StaticPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679565051"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679565049"><span class="hs-identifier hs-type">p</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679565051"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-102"></span><span>
</span><span id="line-103"></span><span class="hs-comment">-- | @since 4.9.0.0</span><span>
</span><span id="line-104"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#IsStatic"><span class="hs-identifier hs-type">IsStatic</span></a></span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-type">StaticPtr</span></a></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-105"></span><span>    </span><span id="local-6989586621679564970"><span class="annot"><span class="annottext">fromStaticPtr :: forall a. StaticPtr a -&gt; StaticPtr a
</span><a href="GHC.StaticPtr.html#fromStaticPtr"><span class="hs-identifier hs-var hs-var hs-var hs-var">fromStaticPtr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StaticPtr a -&gt; StaticPtr a
forall a. a -&gt; a
</span><a href="GHC.Base.html#id"><span class="hs-identifier hs-var">id</span></a></span><span>
</span><span id="line-106"></span><span>
</span><span id="line-107"></span><span class="hs-comment">-- | Miscellaneous information available for debugging purposes.</span><span>
</span><span id="line-108"></span><span class="hs-keyword">data</span><span> </span><span id="StaticPtrInfo"><span class="annot"><a href="GHC.StaticPtr.html#StaticPtrInfo"><span class="hs-identifier hs-var">StaticPtrInfo</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="StaticPtrInfo"><span class="annot"><a href="GHC.StaticPtr.html#StaticPtrInfo"><span class="hs-identifier hs-var">StaticPtrInfo</span></a></span></span><span>
</span><span id="line-109"></span><span>    </span><span class="hs-special">{</span><span> </span><span class="hs-comment">-- | Package key of the package where the static pointer is defined</span><span>
</span><span id="line-110"></span><span>      </span><span id="spInfoUnitId"><span class="annot"><span class="annottext">StaticPtrInfo -&gt; String
</span><a href="GHC.StaticPtr.html#spInfoUnitId"><span class="hs-identifier hs-var hs-var">spInfoUnitId</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-111"></span><span>      </span><span class="hs-comment">-- | Name of the module where the static pointer is defined</span><span>
</span><span id="line-112"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="spInfoModuleName"><span class="annot"><span class="annottext">StaticPtrInfo -&gt; String
</span><a href="GHC.StaticPtr.html#spInfoModuleName"><span class="hs-identifier hs-var hs-var">spInfoModuleName</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span>
</span><span id="line-113"></span><span>      </span><span class="hs-comment">-- | Source location of the definition of the static pointer as a</span><span>
</span><span id="line-114"></span><span>      </span><span class="hs-comment">-- @(Line, Column)@ pair.</span><span>
</span><span id="line-115"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="spInfoSrcLoc"><span class="annot"><span class="annottext">StaticPtrInfo -&gt; (Int, Int)
</span><a href="GHC.StaticPtr.html#spInfoSrcLoc"><span class="hs-identifier hs-var hs-var">spInfoSrcLoc</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-116"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-117"></span><span>  </span><span class="hs-keyword">deriving</span><span> </span><span id="local-6989586621679564950"><span id="local-6989586621679564952"><span id="local-6989586621679564964"><span class="annot"><span class="annottext">Int -&gt; StaticPtrInfo -&gt; ShowS
[StaticPtrInfo] -&gt; ShowS
StaticPtrInfo -&gt; String
(Int -&gt; StaticPtrInfo -&gt; ShowS)
-&gt; (StaticPtrInfo -&gt; String)
-&gt; ([StaticPtrInfo] -&gt; ShowS)
-&gt; Show StaticPtrInfo
forall a.
(Int -&gt; a -&gt; ShowS) -&gt; (a -&gt; String) -&gt; ([a] -&gt; ShowS) -&gt; Show a
showList :: [StaticPtrInfo] -&gt; ShowS
$cshowList :: [StaticPtrInfo] -&gt; ShowS
show :: StaticPtrInfo -&gt; String
$cshow :: StaticPtrInfo -&gt; String
showsPrec :: Int -&gt; StaticPtrInfo -&gt; ShowS
$cshowsPrec :: Int -&gt; StaticPtrInfo -&gt; ShowS
</span><a href="GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span> </span><span class="hs-comment">-- ^ @since 4.8.0.0</span><span>
</span><span id="line-118"></span><span>
</span><span id="line-119"></span><span class="hs-comment">-- | 'StaticPtrInfo' of the given 'StaticPtr'.</span><span>
</span><span id="line-120"></span><span id="local-6989586621679565041"><span class="annot"><a href="GHC.StaticPtr.html#staticPtrInfo"><span class="hs-identifier hs-type">staticPtrInfo</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-type">StaticPtr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679565041"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtrInfo"><span class="hs-identifier hs-type">StaticPtrInfo</span></a></span></span><span>
</span><span id="line-121"></span><span id="staticPtrInfo"><span class="annot"><span class="annottext">staticPtrInfo :: forall a. StaticPtr a -&gt; StaticPtrInfo
</span><a href="GHC.StaticPtr.html#staticPtrInfo"><span class="hs-identifier hs-var hs-var">staticPtrInfo</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.StaticPtr.html#StaticPtr"><span class="hs-identifier hs-type">StaticPtr</span></a></span><span> </span><span class="annot"><span class="annottext">Word#
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Word#
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679564946"><span class="annot"><span class="annottext">StaticPtrInfo
</span><a href="#local-6989586621679564946"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">StaticPtrInfo
</span><a href="#local-6989586621679564946"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-122"></span><span>
</span><span id="line-123"></span><span class="hs-comment">-- | A list of all known keys.</span><span>
</span><span id="line-124"></span><span class="annot"><a href="GHC.StaticPtr.html#staticPtrKeys"><span class="hs-identifier hs-type">staticPtrKeys</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.StaticPtr.html#StaticKey"><span class="hs-identifier hs-type">StaticKey</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-125"></span><span id="staticPtrKeys"><span class="annot"><span class="annottext">staticPtrKeys :: IO [StaticKey]
</span><a href="GHC.StaticPtr.html#staticPtrKeys"><span class="hs-identifier hs-var hs-var">staticPtrKeys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-126"></span><span>    </span><span id="local-6989586621679564945"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679564945"><span class="hs-identifier hs-var">keyCount</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IO CInt
</span><a href="GHC.StaticPtr.html#hs_spt_key_count"><span class="hs-identifier hs-var">hs_spt_key_count</span></a></span><span>
</span><span id="line-127"></span><span>    </span><span class="annot"><span class="annottext">Int -&gt; (Ptr (Ptr Word64) -&gt; IO [StaticKey]) -&gt; IO [StaticKey]
forall a b. Storable a =&gt; Int -&gt; (Ptr a -&gt; IO b) -&gt; IO b
</span><a href="Foreign.Marshal.Array.html#allocaArray"><span class="hs-identifier hs-var">allocaArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679564945"><span class="hs-identifier hs-var">keyCount</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">((Ptr (Ptr Word64) -&gt; IO [StaticKey]) -&gt; IO [StaticKey])
-&gt; (Ptr (Ptr Word64) -&gt; IO [StaticKey]) -&gt; IO [StaticKey]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679564943"><span class="annot"><span class="annottext">Ptr (Ptr Word64)
</span><a href="#local-6989586621679564943"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-128"></span><span>      </span><span id="local-6989586621679564942"><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679564942"><span class="hs-identifier hs-var">count</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr Word64) -&gt; CInt -&gt; IO CInt
forall a. Ptr a -&gt; CInt -&gt; IO CInt
</span><a href="GHC.StaticPtr.html#hs_spt_keys"><span class="hs-identifier hs-var">hs_spt_keys</span></a></span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr Word64)
</span><a href="#local-6989586621679564943"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679564945"><span class="hs-identifier hs-var">keyCount</span></a></span><span>
</span><span id="line-129"></span><span>      </span><span class="annot"><span class="annottext">Int -&gt; Ptr (Ptr Word64) -&gt; IO [Ptr Word64]
forall a. Storable a =&gt; Int -&gt; Ptr a -&gt; IO [a]
</span><a href="Foreign.Marshal.Array.html#peekArray"><span class="hs-identifier hs-var">peekArray</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CInt -&gt; Int
forall a b. (Integral a, Num b) =&gt; a -&gt; b
</span><a href="GHC.Real.html#fromIntegral"><span class="hs-identifier hs-var">fromIntegral</span></a></span><span> </span><span class="annot"><span class="annottext">CInt
</span><a href="#local-6989586621679564942"><span class="hs-identifier hs-var">count</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Ptr (Ptr Word64)
</span><a href="#local-6989586621679564943"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">IO [Ptr Word64]
-&gt; ([Ptr Word64] -&gt; IO [StaticKey]) -&gt; IO [StaticKey]
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span>
</span><span id="line-130"></span><span>        </span><span class="annot"><span class="annottext">(Ptr Word64 -&gt; IO StaticKey) -&gt; [Ptr Word64] -&gt; IO [StaticKey]
forall (t :: * -&gt; *) (m :: * -&gt; *) a b.
(Traversable t, Monad m) =&gt;
(a -&gt; m b) -&gt; t a -&gt; m (t b)
</span><a href="Data.Traversable.html#mapM"><span class="hs-identifier hs-var">mapM</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679564939"><span class="annot"><span class="annottext">Ptr Word64
</span><a href="#local-6989586621679564939"><span class="hs-identifier hs-var">pa</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Int -&gt; Ptr Word64 -&gt; IO [Word64]
forall a. Storable a =&gt; Int -&gt; Ptr a -&gt; IO [a]
</span><a href="Foreign.Marshal.Array.html#peekArray"><span class="hs-identifier hs-var">peekArray</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">Ptr Word64
</span><a href="#local-6989586621679564939"><span class="hs-identifier hs-var">pa</span></a></span><span> </span><span class="annot"><span class="annottext">IO [Word64] -&gt; ([Word64] -&gt; IO StaticKey) -&gt; IO StaticKey
forall (m :: * -&gt; *) a b. Monad m =&gt; m a -&gt; (a -&gt; m b) -&gt; m b
</span><a href="GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var">&gt;&gt;=</span></a></span><span> </span><span class="hs-glyph">\</span><span class="hs-special">[</span><span id="local-6989586621679564938"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679564938"><span class="hs-identifier hs-var">w1</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679564937"><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679564937"><span class="hs-identifier hs-var">w2</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">StaticKey -&gt; IO StaticKey
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="annot"><span class="annottext">(StaticKey -&gt; IO StaticKey) -&gt; StaticKey -&gt; IO StaticKey
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Word64 -&gt; Word64 -&gt; StaticKey
</span><a href="GHC.Fingerprint.Type.html#Fingerprint"><span class="hs-identifier hs-var">Fingerprint</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679564938"><span class="hs-identifier hs-var">w1</span></a></span><span> </span><span class="annot"><span class="annottext">Word64
</span><a href="#local-6989586621679564937"><span class="hs-identifier hs-var">w2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-131"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="GHC.StaticPtr.html#staticPtrKeys"><span class="hs-pragma hs-type">staticPtrKeys</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-132"></span><span>
</span><span id="line-133"></span><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span id="hs_spt_key_count"><span class="annot"><a href="GHC.StaticPtr.html#hs_spt_key_count"><span class="hs-identifier hs-var">hs_spt_key_count</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span>
</span><span id="line-134"></span><span>
</span><span id="line-135"></span><span id="local-6989586621679565032"><span class="hs-keyword">foreign</span><span> </span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-keyword">ccall</span></span><span> </span><span class="annot"><span class="hs-keyword">unsafe</span></span><span> </span><span id="hs_spt_keys"><span class="annot"><a href="GHC.StaticPtr.html#hs_spt_keys"><span class="hs-identifier hs-var">hs_spt_keys</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Ptr.html#Ptr"><span class="hs-identifier hs-type">Ptr</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679565032"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#IO"><span class="hs-identifier hs-type">IO</span></a></span><span> </span><span class="annot"><a href="Foreign.C.Types.html#CInt"><span class="hs-identifier hs-type">CInt</span></a></span></span><span>
</span><span id="line-136"></span></pre></body></html>